<template>
	<view class="Haader">
		<view class="titles">
			<view class="ttile">
				<view class="back">
					<text class="iconfont icon-zuo zuo"></text>
					<view class="return">返回</view>
				</view>
				<view class="life">生活缴费</view>
				<view class="lifeflvg" @click="Go()">添加车辆</view>

			</view>
		</view>
		<view class="CarImg">
			<image src="../../static/images/Cars.png" mode=""></image>
		</view>
		<checkbox-group @change="checkboxChange">
		<view class="CarNumber" v-for="(item,index) in carList" :key="index">
			<view class="iconfont icon-cheliang-">
				<view class="Number">{{item.carno}}</view>
			</view>
			<view class="ChexBox">
					<label>
						<checkbox iconColor="#fff" activeBackgroundColor="#3b85f7" :value="`${item.id}`"/>
					</label>
			</view>
		</view>
		</checkbox-group>
		<view class="DelView" @click="del()">
			删除
		</view>
	</view>
</template>

<script>
	import {
		carList,
		deleteall
	} from "../../apis/index.js"
	export default {
		data() {
			return {
				carList: [],
				ids : [],
				id:[]
			}
		},
		mounted() {
			this.getCar()
		},
		methods: {
			checkboxChange: function(e) {
				this.ids = e.detail.value;
			},
			async del() {
				let res = await deleteall({
					ids : this.ids
				})
				console.log("批量删除我的车辆",this.ids);
				this.$message.success("删除成功")
				this.getCar()

			},
			async getCar() {
				let res = await carList()
				console.log("获取我的车辆", res);
				// res.list.forEach(item=>{
				// 	item.id	
				// 	console.log(item.id,"lll");
				// })
				this.carList = res.list
			},
			Go() {
				uni.navigateTo({
					url: "/pages/addcar/addcar"
				})
			}
		}
	}
</script>

<style lang="less">
	page {
		background-color: #ffffff;

		.CarImg {
			margin-top: 52rpx;

			image {
				width: 100%;
				height: 245rpx;
			}
		}

		.CarNumber {
			display: flex;
			justify-content: space-between;
			margin-top: 40rpx;
			border-bottom: 3rpx solid #eeeeee;
			margin-left: 25rpx;
			padding-bottom: 20rpx;

			.icon-cheliang- {
				font-size: 33rpx;
				background-color: #fff;
				color: #61a0f0;
				padding-left: 32rpx;
				padding-top: 8rpx;
				display: flex;
				align-items: center;

				.Number {
					font-size: 26rpx;
					color: #6b6b6b;
					padding-left: 20rpx;
				}
			}

			.ChexBox {
				margin-right: 20rpx;
			}
		}

		.DelView {
			// width: 100%;
			height: 92rpx;
			background-color: #1f8fff;
			margin: 160rpx 30rpx;
			border-radius: 43rpx;
			text-align: center;
			color: #fff;
			font-size: 34rpx;
			line-height: 92rpx;
			margin-bottom: 200rpx;
		}
	}

	.ttile {
		height: 135rpx;
		background-color: #fff;
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: 28rpx;
		position: relative;

		.back {
			display: flex;

			.zuo {
				font-size: 28rpx;
				padding-left: 13rpx;
				padding-top: 8rpx;
			}

			.return {}
		}

		.lifeflvg {
			padding-right: 10rpx;
			color: #0080fe;
		}
	}

	.Haader {
		padding-bottom: 60rpx;
	}
</style>